#!/usr/bin/env python
# -*- coding: utf-8 -*-


class CategoryNode(object):

    def __init__(self, name, url, parent_name):
        self.name = name
        self.url = url
        self.parent_name = parent_name

    def __eq__(self, other):
        return self.name == other.name

    def __str__(self):
        return "(%s, %s)" % (self.name, self.url)


class CategoryNodes(object):

    def __init__(self):
        self.__nodes = []

    def __exists(self, other):
        for node in self.__nodes:
            if node == other:
                return True
        return False

    def append(self, node):
        if not self.__exists(node):
            self.__nodes.append(node)
            return True
        return False

    def is_empty(self):
        return len(self.__nodes) == 0

    def first_and_remove(self):
        first_node = self.__nodes[0]
        del self.__nodes[0]
        return first_node

    def display(self):
        for node in self.__nodes:
            print node

